import { defineStore } from "pinia";
import { User } from "@/types/user";
import { reactive, ref } from "vue";

type chnl = { content: string; icon: string };
type chnlList = { [key: number]: chnl };

export default defineStore("counterStore", () => {
  const userInfo = ref<User>(<User>{});
  const channelList = reactive<chnlList>({
    3: { content: "影视", icon: "camera" },
    4: { content: "游戏", icon: "game" },
    5: { content: "音乐", icon: "music" },
    6: { content: "学习", icon: "study" },
    7: { content: "美食", icon: "food" },
    8: { content: "日常", icon: "daily" },
    9: { content: "科技", icon: "technology" },
    10: { content: "运动", icon: "sports" },
    11: { content: "动物", icon: "pets" },
    12: { content: "购物", icon: "shopping" },
  });
  const searchContent = ref<string>("");
  const showLoginBox = ref(<boolean>false);
  const setUserInfo = (user: User) => {
    userInfo.value = user;
  };
  const setLoginBox = (flag: boolean) => {
    showLoginBox.value = flag;
  };
  return {
    userInfo,
    channelList,
    searchContent,
    showLoginBox,
    setUserInfo,
    setLoginBox,
  };
});
